﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMD.DataModel.Entity
{
    /** 
 * <p>类说明: 容器</p>
 * @version 1.0
 * <p>文件名： </p>
 * <p>创建人及时间： xiangyuliang 2011-8-27</p>
 * <p>修改人：</p>
 * <p>修改时间：</p>
 * <p>修改描述：</p>
 **/

    public class SpecEntity : BusinessEntity
    {
        private string _entityId;   //实体标识
        private string _specId;  //标本标识
       // private string _parentId; //父节点标识
        private int _freezeThrawTimes; //冻融次数
        private string _sitecode;  //位置编码
        private SpecState _entityState;  //实体状态    
        private DateTime _storedDate;  //存入日期
        private string _customCode; //用户自定义编码
       
        public override void setValue(string key, Object value)
        {
            if (value is System.DBNull)
                return;
            switch (key.ToLower())
            {
                case "entityid":
                    this.Id = (string)value;
                    break;
                case "sitecode":
                    this.SiteCode = (string)value;
                    break;
                case "specid":
                    this.SpecId = (string)value;
                    break;
                case "entitystate":
                    this.EntityState = GetEntityState((string)value);
                    break;
                case "storeddate":
                    this.StoredDate = DateTime.Parse(value.ToString());
                    break;
                case "customcode":
                    this.CustomCode = value.ToString();
                    break;
                default:
                    break;
            }
        }

        private SpecState GetEntityState(string value)
        {
            SpecState state = SpecState.NotUsed;
            switch (value)
            { 
                case "notused":
                    state = SpecState.NotUsed;
                    break;
                case "hasused":
                    state = SpecState.HasUsed;
                    break;
                case "canusedmany":
                    state = SpecState.CanUsedMany;
                    break;
                case "lendout":
                    state = SpecState.LendOut;
                    break;
                case "outlibrary":
                    state = SpecState.OutLibrary;
                    break;
                         
            }
            return state;
                
        }
        public SpecState EntityState
        {
            get
            {
                if (string.IsNullOrEmpty(this.Id))
                    return SpecState.NotUsed;
                return _entityState;
            }
            set
            {
                _entityState = value;
                OnPropertyChanged("EntityState");
            }
        }


        public int FreezeThrawTimes
        {
            get
            {
                return _freezeThrawTimes;
            }
            set
            {
                _freezeThrawTimes = value;
                OnPropertyChanged(() => FreezeThrawTimes);
            }
        }

        public string EntityId
        {
            get
            {
                return EntityId;
            }
            set
            {
                _entityId = value;
                OnPropertyChanged(() => EntityId);
            }
        }

        public string SpecId
        {
            get
            {
                return _specId;
            }
            set
            {
                _specId = value;
                OnPropertyChanged(() => SpecId);
            }
        }
        public string CustomCode
        {
            get
            {
                return _customCode;
            }
            set
            {
                _customCode = value;
                OnPropertyChanged(() => CustomCode);
            }
        }
        public String SiteCode
        {
            get
            {
                return _sitecode;
            }
            set
            {
                _sitecode = value;
                OnPropertyChanged(() => SiteCode);
            }
        }


        public DateTime StoredDate
        {
            get
            {
                return _storedDate;
            }
            set
            {
                _storedDate = value;
                OnPropertyChanged(() => StoredDate);
            }
        }
    }
}
